﻿using System;
using System.Data;
using HRM.Common;
namespace HRM.BusinessLogic
{
    public class WorkingBackgroundInfo
     : Standard_Info
    {
        int _ID;

        public int WB_ID
        {
            get { return _ID; }
            set { _ID = value; }
        }

        string _CompanyName;

        public string WB_CompanyName
        {
            get { return _CompanyName; }
            set { _CompanyName = value; }
        }

        string _Position;

        public string WB_Position
        {
            get { return _Position; }
            set { _Position = value; }
        }

        DateTime _StartDate;

        public DateTime WB_StartDate
        {
            get { return _StartDate; }
            set { _StartDate = value; }
        }

        DateTime _EndDate;

        public DateTime WB_EndDate
        {
            get { return _EndDate; }
            set { _EndDate = value; }
        }

        string _Description;

        public string WB_Description
        {
            get { return _Description; }
            set { _Description = value; }
        }

        int _EmployeeID;

        public int WB_EmployeeID
        {
            get { return _EmployeeID; }
            set { _EmployeeID = value; }
        }

    }
    public class WorkingBackground_Controller : Standard_Controller
    {
        #region "Contructor"
        private static WorkingBackground_Controller _instance;
        protected WorkingBackground_Controller() { }
        protected void Dispose()
        {
            _instance = null;
        }
        private static object _syncLock = new object();
        public static WorkingBackground_Controller Instance()
        {
            if (_instance == null)
            {
                lock (_syncLock)
                {
                    if (_instance == null)
                        _instance = new WorkingBackground_Controller();
                }
            }
            return _instance;
        }
        public static WorkingBackground_Controller Instance(String transName)
        {
            if (!String.IsNullOrEmpty(transName))
            {
                WorkingBackground_Controller _instanceTrans = new WorkingBackground_Controller();
                _instanceTrans.Trans_Name = transName;
                return _instanceTrans;
            }
            else
                return Instance();
        }
        #endregion

        public const String cs_Table_Name = "";

        public DataSet WorkingBackground_GetAll()
        {
            return DataConnect.ExecuteDataset(DataConnect.WorkingConnect, Procedure_Name(cs_Table_Name, "HRM_WorkingBackground_GetAll"));
        }

        public DataSet WorkingBackground_GetList()
        {
            return DataConnect.ExecuteDataset(DataConnect.WorkingConnect, Procedure_Name(cs_Table_Name, "HRM_WorkingBackground_GetList"));
        }

        public DataSet WorkingBackground_GetWithEmployee(int EmployeeID)
        {
            return DataConnect.ExecuteDataset(DataConnect.WorkingConnect, Procedure_Name(cs_Table_Name, "HRM_WorkingBackground_GetWithEmployee"), EmployeeID);
        }

        public WorkingBackgroundInfo WorkingBackground_GetInfo(int WBID)
        {
            return CBO.FillObject<WorkingBackgroundInfo>(DataConnect.ExecuteRow(DataConnect.WorkingConnect, Procedure_Name(cs_Table_Name, "HRM_WorkingBackground_GetInfo"), WBID));
        }

        public int WorkingBackground_Insert(WorkingBackgroundInfo WBInfo)
        {
            return Globals.Object_GetValue<int>(DataConnect.ExecuteScalar(DataConnect.WorkingConnect, Procedure_Name(cs_Table_Name, "HRM_WorkingBackground_Insert"), WBInfo.WB_CompanyName, WBInfo.WB_Position, WBInfo.WB_StartDate, WBInfo.WB_EndDate, WBInfo.WB_Description, WBInfo.WB_EmployeeID));
        }

        public bool WorkingBackground_Update(WorkingBackgroundInfo WBInfo)
        {
            return Globals.Object_GetValue<bool>(DataConnect.ExecuteScalar(DataConnect.WorkingConnect, Procedure_Name(cs_Table_Name, "HRM_WorkingBackground_Update"), WBInfo.WB_ID, WBInfo.WB_CompanyName, WBInfo.WB_Position, WBInfo.WB_StartDate, WBInfo.WB_EndDate, WBInfo.WB_Description, WBInfo.WB_EmployeeID));
        }

        public bool WorkingBackground_UpdateEmployee(int EmployeeID)
        {
            return Globals.Object_GetValue<bool>(DataConnect.ExecuteScalar(DataConnect.WorkingConnect, Procedure_Name(cs_Table_Name, "HRM_WorkingBackground_UpdateEmployee"), EmployeeID));
        }

        public bool WorkingBackground_Delete(int WBID)
        {
            return Globals.Object_GetValue<bool>(DataConnect.ExecuteScalar(DataConnect.WorkingConnect, Procedure_Name(cs_Table_Name, "HRM_WorkingBackground_Delete"), WBID));
        }

        public DataSet WorkingBachgroundList_Report(int BranchID)
        {
            return DataConnect.ExecuteDataset(DataConnect.WorkingConnect, Procedure_Name(cs_Table_Name, "HRM_WorkingBachgroundList_Report"), BranchID);
        }

        public DataSet PositionDetailList_Report(int BranchID)
        {
            return DataConnect.ExecuteDataset(DataConnect.WorkingConnect, Procedure_Name(cs_Table_Name, "HRM_PositionDetail_Report"), BranchID);
        }

        public DataSet LabourContractList_Report(int BranchID)
        {
            return DataConnect.ExecuteDataset(DataConnect.WorkingConnect, Procedure_Name(cs_Table_Name, "HRM_LabourContractList_Report"), BranchID);
        }

        public DataSet EducationList_Report(int BranchID)
        {
            return DataConnect.ExecuteDataset(DataConnect.WorkingConnect, Procedure_Name(cs_Table_Name, "HRM_EducationList_Report"), BranchID);
        }

        public DataSet GradeList_Report(int BranchID)
        {
            return DataConnect.ExecuteDataset(DataConnect.WorkingConnect, Procedure_Name(cs_Table_Name, "HRM_GradeList_Report"), BranchID);
        }

        public DataSet FamilyList_Report(int BranchID)
        {
            return DataConnect.ExecuteDataset(DataConnect.WorkingConnect, Procedure_Name(cs_Table_Name, "HRM_FamilyList_Report"), BranchID);
        }

    }
}
